home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 November: Tool Chest / Dev.CD Nov 98 TC.toast / Sample Code / QuickDraw / TubeTest / TubeTest.r < prev   
Encoding:
Text File  |  1994-11-18  |  12.5 KB  |  363 lines  |  [TEXT/MPS ]

  1. /*------------------------------------------------------------------------------
  2. #
  3. #    Macintosh Developer Technical Support
  4. #
  5. #    Simple Color QuickDraw Animation Sample Application
  6. #
  7. #    TubeTest
  8. #
  9. #    TubeTest.r    -    ResEdit Source
  10. #
  11. #    Copyright © 1988 Apple Computer, Inc.
  12. #    All rights reserved.
  13. #
  14. #    Versions:    1.00                8/88
  15. #                1.01                6/92
  16. #
  17. #    Components:    TubeTest.p            August 1, 1988
  18. #                TubeTest.c            August 1, 1988
  19. #                TubeTest.r            August 1, 1988
  20. #                PTubeTest.make        August 1, 1988
  21. #                CTubeTest.make        August 1, 1988
  22. #                TCTubeTest.π        June 4, 1992
  23. #                TCTubeTest.π.rsrc    June 4, 1992
  24. #
  25. #    The TubeTest program is a simple demonstration of how to use the Palette 
  26. #    Manager in a color program.  It has a special color palette that is associated
  27. #    with the main window.  The colors are animated using the Palette Manager 
  28. #    to give a flowing tube effect.  The program is very simple, and the Palette
  29. #    Manager and drawing parts are put in separate subroutines to make it easier
  30. #    to figure out what is happening.
  31. #    
  32. #    The program is still a complete Macintosh application with a Main Event Loop,
  33. #    so there is the extra code to run the MEL.  
  34. #    
  35. #    There is a resource file that is necessary as well, to define the Menus, Window,
  36. #    Dialog, and Palette resources used in the program.  
  37. #
  38. #    See Sample and TESample for the general structure and MultiFinder techniques that
  39. #    we recommend that you use when building a new application.
  40. #
  41. ------------------------------------------------------------------------------*/
  42.  
  43. #include "Types.r"
  44.  
  45. /* These define's are used in the MENU resources to disable specific
  46.    menu items. */
  47. #define AllItems    0b1111111111111111111111111111111    /* 31 flags */
  48. #define MenuItem1    0b00001
  49. #define MenuItem2    0b00010
  50. #define MenuItem3    0b00100
  51. #define MenuItem4    0b01000
  52. #define MenuItem5    0b10000
  53.  
  54.  
  55. resource 'MENU' (1000, "Apple", preload) {
  56.     1000, textMenuProc,
  57.     AllItems & ~MenuItem2,    /* Disable item #2 */
  58.     enabled, apple,
  59.     {
  60.         "About TubeTest…",
  61.             noicon, nokey, nomark, plain;
  62.         "-",
  63.             noicon, nokey, nomark, plain
  64.     }
  65. };
  66.  
  67. resource 'MENU' (1001, "File", preload) {
  68.     1001, textMenuProc,
  69.     AllItems & ~MenuItem2,    /* Disable item #2 */
  70.     enabled, "File",
  71.     {
  72.         "Totally Tubular",
  73.             noicon, nokey, nomark, plain;
  74.         "-",
  75.             noicon, nokey, nomark, plain;
  76.         "Quit",
  77.             noicon, "Q", nomark, plain
  78.     }
  79. };
  80.  
  81. resource 'MENU' (1002, "Edit", preload) {
  82.     1002, textMenuProc,
  83.     AllItems & ~MenuItem2,    /* Disable items #2 */
  84.     enabled, "Edit",
  85.      {
  86.         "Undo",
  87.             noicon, "Z", nomark, plain;
  88.         "-",
  89.             noicon, nokey, nomark, plain;
  90.         "Cut",
  91.             noicon, "X", nomark, plain;
  92.         "Copy",
  93.             noicon, "C", nomark, plain;
  94.         "Paste",
  95.             noicon, "V", nomark, plain;
  96.         "Clear",
  97.             noicon, nokey, nomark, plain
  98.     }
  99. };
  100.  
  101.  
  102. resource 'WIND' (1000, "Tubeland") {
  103.     {50, 10, 350, 610},
  104.     documentProc, visible, noGoAway, 0x0, "Tubeland"
  105. };
  106.  
  107.  
  108. resource 'DLOG' (1000, "About TubeTest…") {
  109.     {90, 50, 180, 460},
  110.     rDocProc, visible, noGoAway, 0x0, 1000, "TubeAbout"
  111. };
  112.  
  113.  
  114. resource 'DITL' (1000) {
  115.      {
  116. /* 1 */ {60, 167, 81, 244},
  117.         button {
  118.             enabled,
  119.             "OK"
  120.         };
  121. /* 2 */ {5, 10, 60, 400},                /* SourceLanguage Item */
  122.         staticText {
  123.             disabled,
  124.             "Another totally tubular example program from Bo3b Johnson.  "
  125.             "This one shows how to use the Palette Manager, and color animation.  "
  126.             "Version 1.0"
  127.         }
  128.     }
  129. };
  130.  
  131.  
  132. data 'pltt' (1000, preload) {
  133.     $"0098 0000 0000 0000 0000 0000 0000 0000"    /* 150 entries, plus B&W. (152 total) */
  134.  
  135.     $"FFFF FFFF FFFF 0000 0000 0000 0000 0000"    /* white as first guy. */
  136.     $"0000 0000 0000 0002 0000 0000 0000 0000"    /* black as next guy. */
  137.  
  138.     $"FFFF 0000 0000 0004 0000 0000 0000 0000"   /* 25 in first set, ramp up green. */
  139.     $"FFFF 0A40 0000 0004 0000 0000 0000 0000"
  140.     $"FFFF 1480 0000 0004 0000 0000 0000 0000"
  141.     $"FFFF 1EC0 0000 0004 0000 0000 0000 0000"
  142.     $"FFFF 2900 0000 0004 0000 0000 0000 0000"
  143.     $"FFFF 3340 0000 0004 0000 0000 0000 0000"
  144.     $"FFFF 3D80 0000 0004 0000 0000 0000 0000"
  145.     $"FFFF 47C0 0000 0004 0000 0000 0000 0000"
  146.     $"FFFF 5200 0000 0004 0000 0000 0000 0000"
  147.     $"FFFF 5C40 0000 0004 0000 0000 0000 0000"
  148.     $"FFFF 6680 0000 0004 0000 0000 0000 0000"
  149.     $"FFFF 70C0 0000 0004 0000 0000 0000 0000"
  150.     $"FFFF 7B00 0000 0004 0000 0000 0000 0000"
  151.     $"FFFF 8540 0000 0004 0000 0000 0000 0000"
  152.     $"FFFF 8F80 0000 0004 0000 0000 0000 0000"
  153.     $"FFFF 99C0 0000 0004 0000 0000 0000 0000"
  154.     $"FFFF A400 0000 0004 0000 0000 0000 0000"
  155.     $"FFFF AE40 0000 0004 0000 0000 0000 0000"
  156.     $"FFFF B880 0000 0004 0000 0000 0000 0000"
  157.     $"FFFF C2C0 0000 0004 0000 0000 0000 0000"
  158.     $"FFFF CD00 0000 0004 0000 0000 0000 0000"
  159.     $"FFFF D740 0000 0004 0000 0000 0000 0000"
  160.     $"FFFF E180 0000 0004 0000 0000 0000 0000"
  161.     $"FFFF EBC0 0000 0004 0000 0000 0000 0000"
  162.     $"FFFF F600 0000 0004 0000 0000 0000 0000"
  163.  
  164.     $"FFFF FFFF 0000 0004 0000 0000 0000 0000"   /* 2nd set is lowering red. */
  165.     $"F5C0 FFFF 0000 0004 0000 0000 0000 0000"
  166.     $"EB80 FFFF 0000 0004 0000 0000 0000 0000"
  167.     $"E140 FFFF 0000 0004 0000 0000 0000 0000"
  168.     $"D700 FFFF 0000 0004 0000 0000 0000 0000"
  169.     $"CCC0 FFFF 0000 0004 0000 0000 0000 0000"
  170.     $"C280 FFFF 0000 0004 0000 0000 0000 0000"
  171.     $"B840 FFFF 0000 0004 0000 0000 0000 0000"
  172.     $"AE00 FFFF 0000 0004 0000 0000 0000 0000"
  173.     $"A3C0 FFFF 0000 0004 0000 0000 0000 0000"
  174.     $"9980 FFFF 0000 0004 0000 0000 0000 0000"
  175.     $"8F40 FFFF 0000 0004 0000 0000 0000 0000"
  176.     $"8500 FFFF 0000 0004 0000 0000 0000 0000"
  177.     $"7AC0 FFFF 0000 0004 0000 0000 0000 0000"
  178.     $"7080 FFFF 0000 0004 0000 0000 0000 0000"
  179.     $"6640 FFFF 0000 0004 0000 0000 0000 0000"
  180.     $"5C00 FFFF 0000 0004 0000 0000 0000 0000"
  181.     $"51C0 FFFF 0000 0004 0000 0000 0000 0000"
  182.     $"4780 FFFF 0000 0004 0000 0000 0000 0000"
  183.     $"3D40 FFFF 0000 0004 0000 0000 0000 0000"
  184.     $"3300 FFFF 0000 0004 0000 0000 0000 0000"
  185.     $"28C0 FFFF 0000 0004 0000 0000 0000 0000"
  186.     $"1E80 FFFF 0000 0004 0000 0000 0000 0000"
  187.     $"1440 FFFF 0000 0004 0000 0000 0000 0000"
  188.     $"0A00 FFFF 0000 0004 0000 0000 0000 0000"
  189.  
  190.     $"0000 FFFF 0000 0004 0000 0000 0000 0000"   /* 3rd set is raising blue. */
  191.     $"0000 FFFF 0A40 0004 0000 0000 0000 0000"
  192.     $"0000 FFFF 1480 0004 0000 0000 0000 0000"
  193.     $"0000 FFFF 1EC0 0004 0000 0000 0000 0000"
  194.     $"0000 FFFF 2900 0004 0000 0000 0000 0000"
  195.     $"0000 FFFF 3340 0004 0000 0000 0000 0000"
  196.     $"0000 FFFF 3D80 0004 0000 0000 0000 0000"
  197.     $"0000 FFFF 47C0 0004 0000 0000 0000 0000"
  198.     $"0000 FFFF 5200 0004 0000 0000 0000 0000"
  199.     $"0000 FFFF 5C40 0004 0000 0000 0000 0000"
  200.     $"0000 FFFF 6680 0004 0000 0000 0000 0000"
  201.     $"0000 FFFF 70C0 0004 0000 0000 0000 0000"
  202.     $"0000 FFFF 7B00 0004 0000 0000 0000 0000"
  203.     $"0000 FFFF 8540 0004 0000 0000 0000 0000"
  204.     $"0000 FFFF 8F80 0004 0000 0000 0000 0000"
  205.     $"0000 FFFF 99C0 0004 0000 0000 0000 0000"
  206.     $"0000 FFFF A400 0004 0000 0000 0000 0000"
  207.     $"0000 FFFF AE40 0004 0000 0000 0000 0000"
  208.     $"0000 FFFF B880 0004 0000 0000 0000 0000"
  209.     $"0000 FFFF C2C0 0004 0000 0000 0000 0000"
  210.     $"0000 FFFF CD00 0004 0000 0000 0000 0000"
  211.     $"0000 FFFF D740 0004 0000 0000 0000 0000"
  212.     $"0000 FFFF E180 0004 0000 0000 0000 0000"
  213.     $"0000 FFFF EBC0 0004 0000 0000 0000 0000"
  214.     $"0000 FFFF F600 0004 0000 0000 0000 0000"
  215.  
  216.     $"0000 FFFF FFFF 0004 0000 0000 0000 0000"   /* 4th set is lowering green. */
  217.     $"0000 F5C0 FFFF 0004 0000 0000 0000 0000"
  218.     $"0000 EB80 FFFF 0004 0000 0000 0000 0000"
  219.     $"0000 E140 FFFF 0004 0000 0000 0000 0000"
  220.     $"0000 D700 FFFF 0004 0000 0000 0000 0000"
  221.     $"0000 CCC0 FFFF 0004 0000 0000 0000 0000"
  222.     $"0000 C280 FFFF 0004 0000 0000 0000 0000"
  223.     $"0000 B840 FFFF 0004 0000 0000 0000 0000"
  224.     $"0000 AE00 FFFF 0004 0000 0000 0000 0000"
  225.     $"0000 A3C0 FFFF 0004 0000 0000 0000 0000"
  226.     $"0000 9980 FFFF 0004 0000 0000 0000 0000"
  227.     $"0000 8F40 FFFF 0004 0000 0000 0000 0000"
  228.     $"0000 8500 FFFF 0004 0000 0000 0000 0000"
  229.     $"0000 7AC0 FFFF 0004 0000 0000 0000 0000"
  230.     $"0000 7080 FFFF 0004 0000 0000 0000 0000"
  231.     $"0000 6640 FFFF 0004 0000 0000 0000 0000"
  232.     $"0000 5C00 FFFF 0004 0000 0000 0000 0000"
  233.     $"0000 51C0 FFFF 0004 0000 0000 0000 0000"
  234.     $"0000 4780 FFFF 0004 0000 0000 0000 0000"
  235.     $"0000 3D40 FFFF 0004 0000 0000 0000 0000"
  236.     $"0000 3300 FFFF 0004 0000 0000 0000 0000"
  237.     $"0000 28C0 FFFF 0004 0000 0000 0000 0000"
  238.     $"0000 1E80 FFFF 0004 0000 0000 0000 0000"
  239.     $"0000 1440 FFFF 0004 0000 0000 0000 0000"
  240.     $"0000 0A00 FFFF 0004 0000 0000 0000 0000"
  241.  
  242.     $"0000 0000 FFFF 0004 0000 0000 0000 0000"   /* 5th set is raising red. */
  243.     $"0A40 0000 FFFF 0004 0000 0000 0000 0000"
  244.     $"1480 0000 FFFF 0004 0000 0000 0000 0000"
  245.     $"1EC0 0000 FFFF 0004 0000 0000 0000 0000"
  246.     $"2900 0000 FFFF 0004 0000 0000 0000 0000"
  247.     $"3340 0000 FFFF 0004 0000 0000 0000 0000"
  248.     $"3D80 0000 FFFF 0004 0000 0000 0000 0000"
  249.     $"47C0 0000 FFFF 0004 0000 0000 0000 0000"
  250.     $"5200 0000 FFFF 0004 0000 0000 0000 0000"
  251.     $"5C40 0000 FFFF 0004 0000 0000 0000 0000"
  252.     $"6680 0000 FFFF 0004 0000 0000 0000 0000"
  253.     $"70C0 0000 FFFF 0004 0000 0000 0000 0000"
  254.     $"7B00 0000 FFFF 0004 0000 0000 0000 0000"
  255.     $"8540 0000 FFFF 0004 0000 0000 0000 0000"
  256.     $"8F80 0000 FFFF 0004 0000 0000 0000 0000"
  257.     $"99C0 0000 FFFF 0004 0000 0000 0000 0000"
  258.     $"A400 0000 FFFF 0004 0000 0000 0000 0000"
  259.     $"AE40 0000 FFFF 0004 0000 0000 0000 0000"
  260.     $"B880 0000 FFFF 0004 0000 0000 0000 0000"
  261.     $"C2C0 0000 FFFF 0004 0000 0000 0000 0000"
  262.     $"CD00 0000 FFFF 0004 0000 0000 0000 0000"
  263.     $"D740 0000 FFFF 0004 0000 0000 0000 0000"
  264.     $"E180 0000 FFFF 0004 0000 0000 0000 0000"
  265.     $"EBC0 0000 FFFF 0004 0000 0000 0000 0000"
  266.     $"F600 0000 FFFF 0004 0000 0000 0000 0000"
  267.  
  268.     $"FFFF 0000 FFFF 0004 0000 0000 0000 0000"   /* 6th set is lowering blue. */
  269.     $"FFFF 0000 F5C0 0004 0000 0000 0000 0000"
  270.     $"FFFF 0000 EB80 0004 0000 0000 0000 0000"
  271.     $"FFFF 0000 E140 0004 0000 0000 0000 0000"
  272.     $"FFFF 0000 D700 0004 0000 0000 0000 0000"
  273.     $"FFFF 0000 CCC0 0004 0000 0000 0000 0000"
  274.     $"FFFF 0000 C280 0004 0000 0000 0000 0000"
  275.     $"FFFF 0000 B840 0004 0000 0000 0000 0000"
  276.     $"FFFF 0000 AE00 0004 0000 0000 0000 0000"
  277.     $"FFFF 0000 A3C0 0004 0000 0000 0000 0000"
  278.     $"FFFF 0000 9980 0004 0000 0000 0000 0000"
  279.     $"FFFF 0000 8F40 0004 0000 0000 0000 0000"
  280.     $"FFFF 0000 8500 0004 0000 0000 0000 0000"
  281.     $"FFFF 0000 7AC0 0004 0000 0000 0000 0000"
  282.     $"FFFF 0000 7080 0004 0000 0000 0000 0000"
  283.     $"FFFF 0000 6640 0004 0000 0000 0000 0000"
  284.     $"FFFF 0000 5C00 0004 0000 0000 0000 0000"
  285.     $"FFFF 0000 51C0 0004 0000 0000 0000 0000"
  286.     $"FFFF 0000 4780 0004 0000 0000 0000 0000"
  287.     $"FFFF 0000 3D40 0004 0000 0000 0000 0000"
  288.     $"FFFF 0000 3300 0004 0000 0000 0000 0000"
  289.     $"FFFF 0000 28C0 0004 0000 0000 0000 0000"
  290.     $"FFFF 0000 1E80 0004 0000 0000 0000 0000"
  291.     $"FFFF 0000 1440 0004 0000 0000 0000 0000"
  292.     $"FFFF 0000 0A00 0004 0000 0000 0000 0000"
  293.  
  294. /* End of table, all 150 real entries, and 2 for B&W. */
  295. };
  296.  
  297.  
  298. #ifdef MPW2
  299. /* we put the latest SIZE template here so we can rez with MPW 2.0 */
  300.  
  301. type 'SIZE' {
  302.         boolean        dontSaveScreen,
  303.                     saveScreen;
  304.         boolean     ignoreSuspendResumeEvents,
  305.                     acceptSuspendResumeEvents;
  306.         boolean        enableOptionSwitch,
  307.                     disableOptionSwitch;
  308.         boolean        cannotBackground,
  309.                     canBackground;
  310.         boolean        notMultiFinderAware,
  311.                     multiFinderAware;
  312.         boolean        backgroundAndForeground,
  313.                     onlyBackground;
  314.         boolean        dontGetFrontClicks,
  315.                     getFrontClicks;
  316.         unsigned bitstring[9] = 0;
  317.         unsigned longint;    /* preferred memory size in bytes */
  318.         unsigned longint;    /* minimum memory size in bytes */
  319. };    /* ignore the warning caused by re-defining SIZE */
  320.  
  321.  
  322. /* here is the quintessential MultiFinder friendliness device, the SIZE resource */
  323.  
  324. resource 'SIZE' (-1) {
  325.     saveScreen,
  326.     ignoreSuspendResumeEvents,
  327.     disableOptionSwitch,
  328.     cannotBackground,
  329.     NotMultiFinderAware,        /* this says we do our own activate/deactivate; don't fake us out */
  330.     backgroundAndForeground,    /* this is definitely note a background-only application! */
  331.     dontGetFrontClicks,            /* change this is if you want "do first click" behavior like the Finder */
  332.     100 * 1024,                    /* we made this (preferred) size bigger than the other (minimum) size */
  333.                                 /* so you can have more text & scraps */
  334.     100 * 1024                    /* we looked at a heap dump while the program was running */
  335.                                 /* it was using about 27K; we added 13K for stack, text & scraps */
  336. };
  337.  
  338. #else /* not MPW2, i.e. MPW 3 */
  339.  
  340. /* here is the quintessential MultiFinder friendliness device, the SIZE resource */
  341. resource 'SIZE' (-1) {
  342.     saveScreen,
  343.     ignoreSuspendResumeEvents,
  344.     disableOptionSwitch,
  345.     cannotBackground,
  346.     NotMultiFinderAware,        /* this says we do our own activate/deactivate; don't fake us out */
  347.     backgroundAndForeground,    /* this is definitely note a background-only application! */
  348.     dontGetFrontClicks,            /* change this is if you want "do first click" behavior like the Finder */
  349.     ignoreAppDiedEvents,
  350.     is32BitCompatible,
  351.     notHighLevelEventAware,
  352.     onlyLocalHLEvents,
  353.     notStationeryAware,
  354.     dontUseTextEditServices,
  355.     reserved,
  356.     reserved,
  357.     reserved,
  358.     100 * 1024,                    /* we made this (preferred) size bigger than the other (minimum) size */
  359.                                 /* so you can have more text & scraps */
  360.     100 * 1024                    /* we looked at a heap dump while the program was running */
  361.                                 /* it was using about 27K; we added 13K for stack, text & scraps */
  362. };
  363. #endif